<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"> 

    <h:head> 
        <title>SABM</title> 

        <style type="text/css"> 

            .gritter-notice-wrapper { 
                left:200px; 
                top:50px; 
            } 
            
            .order-table{   
                border-collapse:collapse;
            }

            .order-table-header{
                text-align:center;
                background:none repeat scroll 0 0 #E5E5E5;
                border-bottom:1px solid #BBBBBB;
                padding:16px;
            }

            .order-table-odd-row{
                text-align:center;
                background:none repeat scroll 0 0 #FFFFFFF;
                border-top:1px solid #BBBBBB;
            }

            .order-table-even-row{
                text-align:center;
                background:none repeat scroll 0 0 #F9F9F9;
                border-top:1px solid #BBBBBB;
            }
        </style> 
        


    </h:head> 
    <h:body>    
        <ez:TCubeAdminTopMenu/>

        <h1>Stakeholder Account and Billing Management</h1> 

        <p:layout style="table-layout:auto; height:800px ">
            <p:layoutUnit position="left" header="Navigation" width="300">
                <h:form id="SABMTCubeAdminSM">
                         <h:commandLink value="Add Stakeholder" action="/TCubeAdmin/SABM_SM/addStakeholder.xhtml?faces-redirect=true"/>
                    <br/>
                    <h:commandLink value="Delete Stakeholder" action="/TCubeAdmin/SABM_SM/deleteStakeholder.xhtml?faces-redirect=true"/>
                    <br/>
                    <h:commandLink value="Change Stakeholder Tier" action="/TCubeAdmin/SABM_SM/changeStakeholderTier.xhtml?faces-redirect=true"/>
                    <br/>
                    <h:commandLink value="Create Stakeholder Tier" action="/TCubeAdmin/SABM_SM/createNewTier.xhtml?faces-redirect=true"/>
                    <br/>
                     <h:commandLink value="Delete Stakeholder Tier" action="/TCubeAdmin/SABM_SM/deleteTier.xhtml?faces-redirect=true"/>
                    <br/>
                    <h:commandLink value="Modify Tier Information" action="/TCubeAdmin/SABM_SM/modifyTier.xhtml?faces-redirect=true"/>
                    <br/>
                </h:form>
            </p:layoutUnit>
            <p:layoutUnit position="center" header="Settings">
        <h2>Modify Stakeholder Tier Information</h2>
    	<h:form id="tierUpdateForm">
         
            <br/>
    		<p:dataTable value="#{tierManagerBean.allTiers}" var="o"
                             onRowSelectUpdate="tierUpdateForm"
                             selection="#{tierManagerBean.selectedTier}"
                             selectionMode="single"
                             rowSelectListener="#{tierManagerBean.updateFields()}"
    			styleClass="order-table"
    			
    		>
 
             <p:column>
                <f:facet name="header">Tier Name</f:facet>
    		<h:outputText id="name" value="#{o.name}" />
    	     </p:column>
 
    	     <p:column>
    		<f:facet name="header">Commission Percentage</f:facet>
    		<h:outputText id="commissionPercent" value="#{o.commissionPercent}"  />
    	     </p:column>
 
    	     <p:column>
    		<f:facet name="header">Subscription Fee</f:facet>
    		<h:outputText value="#{o.feeSubscription}">
                    <f:convertNumber type ="currency" currencySymbol ="$"/>
                </h:outputText>
    	     </p:column>
 
    	     <p:column>
    		<f:facet name="header">Market Intelligence Fee</f:facet>         
    		<h:outputText value="#{o.feeMarketIntelligence}" >
                    <f:convertNumber type ="currency" currencySymbol ="$"/>
                </h:outputText>
    	     </p:column>
                    
             <p:column>
     		<f:facet name="header">Cost Per Click</f:facet>
     		<h:outputText value="#{o.costPerClick}">
                    <f:convertNumber type ="currency" currencySymbol ="$"/>
                </h:outputText>
    	     </p:column>   
 
    	 
    	  </p:dataTable>
        
        
            
    	  <br/>
          
          <h3>Click on a row above to edit a tier</h3>
          
           <p:panel id="panel" >
                    <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />   
          
              <h:outputText value="Tier Name: "  />  <h:outputText value="#{tierManagerBean.name}"/>
              <h:inputHidden value="#{tierManagerBean.name}"/>
              
          <br/>
              <h:outputText value="Commission Percent: "  /> <h:inputText value="#{tierManagerBean.commissionPercent}"  /><br/>
              <h:outputText value="Subscription Fee: "  /> <h:inputText value="#{tierManagerBean.feeSubscription}"  /><br/>
              <h:outputText value="Market Intelligence Fee: "  /> <h:inputText value="#{tierManagerBean.feeMarketIntelligence}"  /><br/>
              <h:outputText value="Advertising Cost Per Click: "  /> <h:inputText value="#{tierManagerBean.costPerClick}"  /><br/>
            
              <h:commandButton value="Modify This Tier" 
                                onclick="if (!confirm('Are you sure you want to modify tier?')) return false"
                                    action="#{tierManagerBean.modifyTier}"
                                    />
                                             
         
                  
                  <br/>
          
         </p:panel>
 
      </h:form>
         </p:layoutUnit>
        </p:layout>
    </h:body>	
</html>